By plane
The Rabat International Airport is in the nearby town of Salé. The city has limited international connections, with most tourist flying into nearby Casablanca and then coming into Rabat by train or coach. There are flights every day between Rabat and Paris, the french Capital.The airport itself is very tiny, possessing limited facilities only one runway, one conveyor belt, etc. so it's definitely not the best way to get into the city. However, the airport is undergoing some major renovations, with the hope of relieving all the flights from Fez, Marrakesh and Casablanca, so it should improve in the not too distant future.
By train
Rabat is well served by train and you can get frequent connections to most places. Marrakesh is a pleasant 4 hour journey, Fez 2.5 hours if you take one of the new express trains, and 3.5 hours on other trains and Casablanca 1 hour. There are two stations in Gare Rabat Ville. edit Medina/Downtown and Agdal. A tram and a taxi station are located just next to the downtown train station. Be warned that some travelers report that trains are frequently delayed by over an hour. Visit OCNF website ocnf for the timetable.
By bus
It's possible to get a bus from almost any town in the country to Rabat. Note, however, that the buses often do not stop at the central bus station, but instead go through the city. It may be a good idea to ask someone which is the correct stop, or use a decent street map to work out where you are. It is easy to miss the main stop and find yourself heading out into the suburbs again, which is not too bad - about a 20-25 MAD ride in to downtown.